package plus;

public class Gripe extends RuntimeException {
	private static final long serialVersionUID = 66420602859850025L;
	
	public static Object context;
	public static int lineNr;
	public static void toss(String s) { throw new Gripe(s); }
	public Gripe(String string) {
		super(string);
	}
	public Gripe(int lineNr, String string) {
		super(string);
		Gripe.lineNr = lineNr;
	}
	public static void gripe(int ln, String about) { lineNr = ln; gripe(about); }
	public static void gripe(String about) {
		throw new Gripe(lineNr+": "+about+" in "+context);
	}

	public void display() {
		System.err.println(":::::::::::::");
		System.err.println(": PLUS: Semantic Error");
		if (lineNr != 0) System.err.println(": near line "+lineNr);
		if (context != null) System.err.println(": in "+context);
		System.err.println("=============");
		System.err.println(getMessage());
	}

}
